CFLAGS = -fpic -coverage -lm -std=c99

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)
	
testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

runtests: testDrawCard 
	./testDrawCard &> unittestresult.out
	gcov dominion.c >> unittestresult.out
	cat dominion.c.gcov >> unittestresult.out

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

unittest1.o: unittest1.c dominion.o rngs.o
	gcc -o unittest1.o -g unittest1.c dominion.o rngs.o $(CFLAGS)

unittest2.o: unittest2.c dominion.o rngs.o
	gcc -o unittest2.o -g unittest2.c dominion.o rngs.o $(CFLAGS)

unittest3.o: unittest3.c dominion.o rngs.o
	gcc -o unittest3.o -g unittest3.c dominion.o rngs.o $(CFLAGS)

unittest4.o: unittest4.c dominion.o rngs.o
	gcc -o unittest4.o -g unittest4.c dominion.o rngs.o $(CFLAGS)

unittestresults.out: unittest1.o unittest2.o unittest3.o unittest4.o
	touch unittestresults.out
	rm unittestresults.out
	./unittest1.o > unittestresults.out
	./unittest2.o >> unittestresults.out
	./unittest3.o >> unittestresults.out
	./unittest4.o >> unittestresults.out
	
randomtestcard.o: randomtestcard.c dominion.o rngs.o
	gcc -o randomtestcard.o -g randomtestcard.c dominion.o rngs.o $(CFLAGS)
	
randomtestadventurer.o: randomtestadventurer.c dominion.o rngs.o
	gcc -o randomtestadventurer.o -g randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	
randomtestcard.out: randomtestcard.o
	touch randomtestcard.out
	rm randomtestcard.out
	./randomtestcard.o > randomtestcard.out

randomtestadventurer.out: randomtestadventurer.o
	touch randomtestadventurer.out
	rm randomtestadventurer.out
	./randomtestadventurer.o > randomtestadventurer.out

all: playdom player testDrawCard testBuyCard badTestDrawCard unittest1.o unittest2.o unittest3.o unittest4.o randomtestcard.o randomtestadventurer.o randomtestcard.out randomtestadventurer.out

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testInit testInit.exe *.gcov *.gcda *.gcno *.so
